package com.lims.algorithm.algset.recursive;

import java.util.Scanner;

/**
 * <功能简述>
 *
 * @author lims
 * @date 2020-04-26 15:34
 */
public class ReverseStr {
    public static void main(String[] args) {
        System.out.println("输入字符串:");
        Scanner in = new Scanner(System.in);
        String str = in.next();
        String reverseStr = reverseStrRecur(str);
        System.out.println("反转后：" + reverseStr);
    }

    public static String reverseStrRecur(String word) {
        if (word == null || "".equals(word)) {
            return "";
        }
        String subStr = reverseStrRecur(word.substring(1));
        String reverseStr = subStr.concat(word.substring(0, 1));
        return reverseStr;
    }
}
